package google.sites.view.dialogs;

import dev.tools.view.dialogs.FormDialog;
import google.sites.model.commands.webpage.CreateWebPage;
import google.sites.view.View;

import javax.swing.*;

/**
 * Created with IntelliJ IDEA.
 * User: Nuno
 * Date: 05-10-2013
 * Time: 14:52
 */
public class CreateWebPageDialog extends FormDialog<CreateWebPage> {
    private final JTextField titleField;
    private String parentId;

    public CreateWebPageDialog(String parentId) {
        super(View.INSTANCE, new CreateWebPage());
        this.parentId = parentId;
        titleField = addField("Title", new JTextField(20));
    }

    @Override
    protected void onExecuting() {
        command
                .setTitle(titleField.getText())
                .setParentId(parentId);
    }
}
